/*
 * ArrayList.hpp
 *
 *  Created on: Apr 25, 2011
 *      Author: nathanielclinger
 */

#ifndef ARRAYLIST_HPP_
#define ARRAYLIST_HPP_

#ifndef NULL
#define NULL ((void *)0)
#endif

#include <iostream>

using namespace std ;

template <class T>
class ArrayList
{
	private:
		int current, top ;	// current is the length, and top is the max size of the array
		T * al ;			// pointer to array
		void memoryAllocator( T * p, int * n ) ;

	public:
		ArrayList() ;	// default constructor is the only one
		ArrayList( ArrayList<T> &other ) ;
		ArrayList( const ArrayList<T> &other ) ;
		~ArrayList() ;
		void add( T &ob ) ;
		void clear() ;
		bool isEmpty() ;
		T& get( int n ) ;
		void set( T &ob, int n ) ;
		int length() ;
		void empty() ;
		void insert( T &ob, int n ) ;	// insert object of type T in position n
		bool find( T &ob ) ;
		void load( char *p ) ;
		void save( char *p ) ;
		void print() ;
		const ArrayList<T> operator+( const ArrayList<T> &other ) ;
		ArrayList<T> &operator=( const ArrayList<T> &assign ) ;
		bool operator==( const ArrayList<T> &other ) ;
		bool operator!=( const ArrayList<T> &other ) ;

		template<class Y>
		friend ostream& operator<<( ostream&, const ArrayList<Y>& ) ;
};

#include "ArrayList.cpp"
#include "ArrayList.op.cpp"

#endif /* ARRAYLIST_HPP_ */
